package com.logbug.designpatterns;

interface Person {
    void useKnife();
}
class Hero implements Person {

    @Override
    public void useKnife() {
        System.out.println("英雄用刀保护人！");
    }
}
class BadGuy implements Person {

    @Override
    public void useKnife() {
        System.out.println("坏人用刀害人！");
    }
}
class Knife {
    public void accept(Person visitor) {
        visitor.useKnife();
    }
}
public class TestVisit {
    public static void main(String[] args) {
        Knife knife = new Knife();
        knife.accept(new Hero());
        knife.accept(new BadGuy());
    }
}
